#include "operatortable.h"

OperatorTable::OperatorTable()
{

}

double OperatorTable::operate(double num1, char oper, double num2)
{
    if (oper == '+') {
        return num1 + num2;
    }
    if (oper == '-') {
        return num1 - num2;
    }
    if (oper == '*') {
        return num1 * num2;
    }
    if (oper == '/') {
        return num1 / num2;
    }
    return 0;
}

int OperatorTable::findIndex(char oper)
{
    if (oper == '+') {
        return 0;
    }
    else if (oper == '-') {
        return 1;
    }
    else if (oper == '*') {
        return 2;
    }
    else if (oper == '/') {
        return 3;
    }
    else if (oper == '#') {
        return 4;
    }
    return -1;
}

char OperatorTable::precede(char o1, char o2)
{
    return priorityList[findIndex(o1)][findIndex(o2)];
}



